﻿var ocxobj = document.getElementById("clientd1");
window.onbeforeunload = function (e) {
	//CloseAllVideo(1);
	LoginOut(405);
}
function loginOcx(win) {
	ocxobj = document.getElementById("clientd1");
	//ocxobj.IRV_Login("172.126.10.11", 5100, "admin", "admin", "44030900002006000001", 500, 500);
	ocxobj.IRV_Login("59.37.56.51", 12121, "admin", "admin", "45040000582000000001", 405, 405);
	//ocxobj.IRV_Login("192.168.1.240", 12121, "admin", "admin", "1-0-1", 405, 405); //"192.168.1.242", 12121, "sys", "sys","405"
	//ocxobj.IRV_Login("192.168.1.240", 5060, "admin", "admin", "44010700002000000001", 500, 500);
	ocxobj.IRV_ChangeWindows(win);

}
function initOpenVideo(id) {
	//var videos = ["1-4-12", "1-4-13", "1-4-5", "1-4-6", "1-4-7"];
	//var int = Math.floor(Math.random() * 5);
	OpenVideo(id, 405);
}
function ChangeWindows(num) {
	ocxobj.IRV_ChangeWindows(num);//调用OCX
	//window.external.IRV_ChangeWindows(num); //调用Winform 
}
function OpenVideo(id, sysid) {
	for (var i = 0; i < 3; i++) {
		CloseVideo();
	}
	CloseVideo();
	if (id.indexOf(",") == -1) {
		ocxobj.OpenVideo(id, sysid); //调用OCX
	} else {
		var ids = id.split(",");
		for (var i = 0; i < ids.length; i++) {
			ocxobj.OpenVideo(ids[i], sysid);
		}
	}

	//window.external.OpenVideo(id, sysid); //调用Winform 
}
function CloseVideo() {
	ocxobj.CloseVideo();//调用OCX
	//window.external.CloseVideo(); //调用Winform 
}
function CloseAllVideo(type) {
	ocxobj.CloseAllVideo();//调用OCX
	//window.external.CloseAllVideo(); //调用Winform 
}
function LoginOut(sysid) {
	ocxobj.LoginOut(sysid);//调用OCX
	//window.external.LoginOut(sysid); //调用Winform 
}
function closeVideoDiv() {
	$("#video").css("display", "none");
	CloseVideo();
}

var myPlayer1 = null;
function initVideoPlayCom(id) {
	
	myPlayer1 = videojs(id);
	videojs(id).ready(function () {
		myPlayer1 = this;
	});
	closeVideoPlayCom();
	setTimeout(function () {
		$("#"+id).css({ "height": "360px", "width": "475px", "margin-top": "7%","margin-left":"2.5%" });
	}, 500)
	//$(".video-js .vjs-big-play-button").css("display", "none");
}
function videoPlayCom(videos) {
	if (videos != "" && videos != null) {
		var data = eval(videos);
		if (data.length > 0) {
			openVideoPlayCom(data[0].url);
		}
	}
}
function openVideoPlayCom(src) {
	var playsrc = videoUrl + src;
	myPlayer1.src(playsrc); /*动态设置video.js播放的地址。*/

	setTimeout(function () {
		if (playsrc != defeatVideoUrl) {
			myPlayer1.play();
		}
	}, 500);
}
/*关闭所有窗口监控*/
function closeVideoPlayCom() {
	//myPlayer1.src(defeatVideoUrl);
	$("#video").css("display", "none");
}